#include <iostream>
#include <string>
#include <jsoncpp/json/json.h>

int main()
{
    Json::Value root;
    root["x"] = 100;
    root["y"] = 200;
    root["op"] = '+';
    root["desc"] = "this is a + oper";

    // 序列化
    Json::FastWriter w;
    // Json::StyledWriter w;
    std::string res = w.write(root);
    std::cout << res << std::endl;

    //反序列化
    Json::Value r_root;
    Json::Reader r;
    r.parse(res, r_root);
    int x = r_root["x"].asInt();
    int y = r_root["y"].asInt();
    char op = r_root["op"].asInt();
    std::string desc = r_root["desc"].asString();
    std::cout << x << ' ' << y << ' ' << op << ' ' << desc << std::endl;

    return 0;
}